{% load staticfiles %}
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="description" content="">
        <meta name="author" content="">

        <link rel="shortcut icon" href="{% static '' %}velonic/img/favicon_1.ico">

        <title>物流管理&优化</title>

        <!-- DataTables -->
        <link href="{% static '' %}velonic/css/datatables/jquery.dataTables.min.css" rel="stylesheet" type="text/css" />
        <link href="{% static '' %}velonic/css/datatables/buttons.bootstrap.min.css" rel="stylesheet" type="text/css" />
        <link href="{% static '' %}velonic/css/datatables/fixedHeader.bootstrap.min.css" rel="stylesheet" type="text/css" />
        <link href="{% static '' %}velonic/css/datatables/responsive.bootstrap.min.css" rel="stylesheet" type="text/css" />
        <link href="{% static '' %}velonic/css/datatables/scroller.bootstrap.min.css" rel="stylesheet" type="text/css" />

        <!-- Bootstrap core CSS -->
        <link href="{% static '' %}velonic/css/bootstrap.min.css" rel="stylesheet">
        <link href="{% static '' %}velonic/css/bootstrap-reset.css" rel="stylesheet">
        <link href="{% static '' %}velonic/css/bootstrap-datetimepicker.min.css" rel="stylesheet">

        <!--Animation css-->
        <link href="{% static '' %}velonic/css/animate.css" rel="stylesheet">

        <!--Icon-fonts css-->
        <link href="{% static '' %}velonic/css/font-awesome.css" rel="stylesheet" />
        <link href="{% static '' %}velonic/css/ionicons.min.css" rel="stylesheet" />
        <link href="{% static '' %}velonic/css/material-design-iconic-font.min.css" rel="stylesheet" />

        <!-- Plugins css -->
        <link href="{% static '' %}velonic/css/component.css" rel="stylesheet">


        <!-- Custom styles for this template -->
        <link href="{% static '' %}velonic/css/style.css" rel="stylesheet">
        <link href="{% static '' %}velonic/css/helper.css" rel="stylesheet">
        

        <!-- HTML5 shim and Respond.js IE8 support of HTML5 tooltipss and media queries -->
        <!--[if lt IE 9]>
          <script src="js/html5shiv.js"></script>
          <script src="js/respond.min.js"></script>
        <![endif]-->


    </head>


    <body onload="getOvertimeCountry();getExceptionRate();">

        <!-- Aside Start-->
        {% include 'velonic/block/side_nav.html' %}
        <!-- Aside Ends-->


        <!--Main Content Start -->
        <section class="content">
            
            <!-- Header -->
            {% include 'velonic/block/header.html' %}
            <!-- Header Ends -->


            <!-- Page Content Start -->
            <!-- ================== -->

            <div class="wraper container-fluid">
                <div class="page-title"> 
                    <h3 class="title">物流监控</h3>
                </div>


                <div class="row">
                    <div class="col-md-12">
                        <div class="panel panel-default">
                            <div class="panel-heading">
                                <h3 class="panel-title">物流渠道评估</h3>
                            </div>


                            <div class="form-inline p-20" id="">
                                <fieldset>
                                    <div class="form-group">
                                        <label for="startDate" class="col-md-2 control-label" style="line-height: 36px;">从</label>
                                        <div class="input-group date form_date col-md-3" data-date="" data-date-format="yyyy-mm-dd" data-link-field="startDate" data-link-format="yyyy-mm-dd">
                                            <input class="form-control" size="16" type="text" value="{{ mindate.send_time|date:'Y-m-d' }}" readonly style="min-width: 100px;background: #fff;">
                                            <span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>
                                            <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
                                        </div>
                                        <input type="hidden" id="startDate" name="startDate" value="{{ mindate.send_time|date:'Y-m-d' }}" /><br/>
                                    </div>
                                    <div class="form-group">
                                        <label for="endDate" class="col-md-2 control-label" style="line-height: 36px;">到</label>
                                        <div class="input-group date form_date col-md-3" data-date="" data-date-format="yyyy-mm-dd" data-link-field="endDate" data-link-format="yyyy-mm-dd">
                                            <input class="form-control" size="16" type="text" value="{{ maxdate.send_time|date:'Y-m-d' }}" readonly style="min-width: 100px;background: #fff;">
                                            <span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>
                                            <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
                                        </div>
                                        <input type="hidden" id="endDate" name="endDate" value="{{ maxdate.send_time|date:'Y-m-d' }}" /><br/>
                                    </div>
                                    <button type="button" class="btn btn-success m-l-10" id="timeBtn">提交</button>
                                    <a href="{% url 'logistics_list' %}" class="pull-right">最近90天物流统计</a>
                                </fieldset>

                            </div>


                            <div class="panel-body">



                                <div class="row">
                                    <div class="col-md-12 col-sm-12 col-xs-12">
                                            <table class="table" id="table-evaluate">
                                                <thead>
                                                <tr>
                                                    <th>渠道</th>
                                                    <th>成功投递数</th>
                                                    <th>成功签收率</th>
                                                    <th>签收平均时间</th>
                                                    <th>运输超过30天的国家</th>
                                                    <th>#</th>
                                                </tr>
                                                </thead>
                                                <tbody class="tbPinggu">
            {% for c in channelData %}
              <tr>
                <td>{{ c.Channel }}</td>
                <td>{{ c.Amount }}</td>
                <td>{{ c.DSR }}</td>
                <td>{{ c.Days }}</td>
                <td class="overtimeCountry" channel-data="{{ c.Channel }}"></td>
                <td><a href="#" class="md-trigger btn btn-info btn-sm" onclick="getInfoByChannel('{{ c.Channel }}')" data-toggle="modal" data-target="#channelModal">查看详情</a></td>
              </tr>
            {% endfor %}
            </tbody>
                                            </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>


                <div class="row">
                            <div class="col-md-12">
                                <div class="panel panel-default">
                                    <div class="panel-heading">
                                        <h3 class="panel-title">物流延时警告</h3>
                                        <div>超过 ：
                     <select name="yujing" id="yujing">
                 <option value="10" {% ifequal yj '10' %}selected{% endifequal %}>10天</option>
                 <option value="15" {% ifequal yj '15' %}selected{% endifequal %}>15天</option>
                 <option value="20" {% ifequal yj '20' %}selected{% endifequal %}>20天</option>
                 <option value="30" {% ifequal yj '30' %}selected{% endifequal %}>30天</option>
             </select>
             </div>
                                    </div>
                                    <div class="panel-body">
                                        <div class="row">
                                            <div class="col-md-12 col-sm-12 col-xs-12">
                                                <table id="datatable" class="table table-striped table-bordered">
                                                    <thead>
                                                        <tr>
                                                            <th>物流单号</th>
                                                            <th>物流渠道</th>
                                                            <th>发货时间</th>
                                                            <th>运送时长</th>
                                                            <th>总运输时间</th>
                                                            <th>＃操作</th>
                                                        </tr>
                                                    </thead>


                                                    <tbody class="yjtable">
            {% for l in yujing %}
              <tr id="yj-{{ l.id }}">
                <td><div id="TRNum-{{ l.id }}"></div><a href="javascript:void(0)" onClick="doTrack('{{ l.tracking_number }}','{{ l.id }}')"><i class="zmdi zmdi-search-in-page"></i>{{ l.tracking_number }}</a></td>
                <td>{{ l.channel }}</td>
                <td>{{ l.send_time|date:"Y-m-d H:i:s" }}</td>
                <td>{{ l.num1 }} <i class="glyphicon glyphicon-pencil" title="纠错" onclick="edit('{{ l.tracking_number }}','{{ l.status }}','{{ l.num1 }}')" data-toggle="modal" data-target="#editModal"></i></td>
                <td>{{ l.num2 }} </td>
                <td><button type="button" class="btn btn-warning btn-xs" onclick="mark({{ l.id }})">标记已处理</button></td>
              </tr>
            {% endfor %}
            </tbody>
                                                </table>

                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>

                        </div> <!-- End Row -->


                        <div class="row">
                            <div class="col-md-12">
                                <div class="panel panel-default">
                                    <div class="panel-heading">
                                        <h3 class="panel-title">物流运输异常</h3>
                                        <div>超过 ：
                                             <select name="yichang" id="yichang">
                                         <option value="10" {% ifequal yc '10' %}selected{% endifequal %}>10天</option>
                                         <option value="20" {% ifequal yc '20' %}selected{% endifequal %}>20天</option>
                                         <option value="30" {% ifequal yc '30' %}selected{% endifequal %}>30天</option>
                                         <option value="40" {% ifequal yc '40' %}selected{% endifequal %}>40天</option>
                                     </select>
                                     </div>
                                    </div>
                                    <div class="panel-body">

                                        <table id="datatable-buttons" class="table table-striped table-bordered">
                                            <thead>
                                                <tr>
                                                    <th>物流单号</th>
                                                    <th>物流渠道</th>
                                                    <th>发货时间</th>
                                                    <th>运送时长</th>
                                                    <th>国家</th>
                                                    <th>60天该国家异常率</th>
                                                    <th>#操作</th>
                                                </tr>
                                            </thead>


                                            <tbody class="yctable">
            {% for l in yichang %}
              <tr id="yc-{{ l.id }}">
                <td><div id="TRNum-{{ l.id }}"></div><a href="javascript:void(0)" onClick="doTrack('{{ l.tracking_number }}','{{ l.id }}')"><i class="zmdi zmdi-search-in-page"></i>{{ l.tracking_number }}</a></td>
                <td>{{ l.channel }}</td>
                <td>{{ l.send_time|date:"Y-m-d H:i:s" }}</td>
                <td>{{ l.num1 }} <i class="glyphicon glyphicon-pencil" title="纠错" onclick="edit('{{ l.tracking_number }}','{{ l.status }}','{{ l.num1 }}')" data-toggle="modal" data-target="#editModal"></i></td>
                <td>{{ l.destination }}</td>
                <td class="exceptionRate" dest-data="{{ l.destination }}"></td>
                <td><button type="button" class="btn btn-danger btn-xs" onclick="mark({{ l.id }})">标记已处理</button></td>
              </tr>
            {% endfor %}
            </tbody>



                                        </table>

                                    </div>
                                </div>
                            </div>

                        </div> <!-- End Row -->



                <div class="row">
                <div class="col-md-12">
                <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title">国家运输效率统计</h3>
                </div>
                <div class="panel-body">
                <table id="datatable-responsive" class="table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%">
                    <thead>
                    <tr>
                        <th>国家</th>
                        <th>最优物流渠道</th>
                        <th>平均运输总时长</th>
                        <th>90天内成功签收率</th>
                        <th>统计数量</th>
                        <th>#操作</th>
                    </tr>
                    </thead>


                    <tbody>

                   {% for data in countryData %}
            <tr>
                <td>{{ data.Country }}</td>
                <td>{{ data.Channel }}</td>
                <td>{{ data.Days }}</td>
                <td>{{ data.DSR }}%</td>
                <td>{{ data.Amount }}</td>
                <td><button type="button" class="btn btn-info btn-sm" onclick="getInfoByCountry('{{ data.Country }}')" data-toggle="modal" data-target="#countryModal">
查看详情</button></td>
              </tr>
        {% endfor %}

                    </tbody>
                </table>

                </div>
                </div>
                </div>

                </div> <!-- End Row -->


                

            </div>

            <!-- Page Content Ends -->
            <!-- ================== -->

            <!-- Footer Start -->
            {% include 'velonic/block/footer.html' %}
            <!-- Footer Ends -->



        </section>
        <!-- Main Content Ends -->



        <div id="countryModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="countryModal" aria-hidden="true" style="display: none;">
            <div class="modal-dialog" style="width:55%;">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                        <h4 class="modal-title" class="myModalLabel"><span class="countryName">俄罗斯</span>（60天内数据）</h4>
                    </div>
                    <div class="modal-body">
                        <table class="table table-striped">
                        <thead>
                          <tr>
                            <th>物流渠道</th>
                            <th>总运输时间</th>
                            <th>成功签收率</th>
                            <th>统计数</th>
                          </tr>
                        </thead>
                        <tbody class="winList">

                        </tbody>
                      </table>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                    </div>
                </div><!-- /.modal-content -->
            </div><!-- /.modal-dialog -->
        </div><!-- /.modal -->




        <div id="editModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
            <div class="modal-dialog">
                <div class="modal-content p-0 b-0">
                    <div class="panel panel-color panel-primary">
                        <div class="panel-heading">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                            <h3 class="panel-title" id="myEditModal"><span></span>物流信息纠错</h3>
                        </div>
                        <div class="panel-body">
                            物流状态：
                            <select name="statusData" id="statusData">
                                <option value="1">妥投</option>
                                <option value="2">已签收</option>
                                <option value="3">异常</option>
                                <option value="4">运输中</option>
                                <option value="5">查询不到</option>
                                <option value="6">跟踪结束</option>
                                <option value="7">运输过久</option>
                                <option value="8">投寄失败</option>
                            </select>
                            运送时长：<input type="text" name="dayData" id="dayData" style="width:60px;"> 天
                            <button class="btn btn-sm btn-primary" style="margin-left: 60px;" id="saveBtn">保 存</button>
                        </div>
                    </div>
                </div><!-- /.modal-content -->
            </div><!-- /.modal-dialog -->
        </div><!-- /.modal -->




        <div class="modal fade" id="channelModal" tabindex="-1" role="dialog" aria-labelledby="channelModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
        <h4 class="modal-title" class="channelModalLabel"><span class="channelName"></span>	（60天内数据）</h4>
      </div>
      <div class="modal-body">
        <table class="table table-striped">
            <thead>
              <tr>
                <th>国家</th>
                <th>总运输时间</th>
                <th>成功签收率</th>
                <th>统计数量</th>
              </tr>
            </thead>
            <tbody class="cnList">

            </tbody>
          </table>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
      </div>
    </div>
  </div>
</div>

        <!-- the overlay element -->
        



        <!-- js placed at the end of the document so the pages load faster -->
        <script src="{% static '' %}velonic/js/jquery.js"></script>
        <script src="{% static '' %}velonic/js/bootstrap.min.js"></script>
        <script src="{% static '' %}velonic/js/pace.min.js"></script>
        <script src="{% static '' %}velonic/js/wow.min.js"></script>
        <script src="{% static '' %}velonic/js/jquery.nicescroll.js" type="text/javascript"></script>

        <!-- Modal-Effect -->
        <script src="{% static '' %}velonic/js/classie.js"></script>

        <script src="{% static '' %}velonic/js/jquery.app.js"></script>

        <!-- Datatables-->
        <script src="{% static '' %}velonic/js/datatables/jquery.dataTables.min.js"></script>
        <script src="{% static '' %}velonic/js/datatables/dataTables.bootstrap.js"></script>
        <script src="{% static '' %}velonic/js/datatables/dataTables.buttons.min.js"></script>
        <script src="{% static '' %}velonic/js/datatables/buttons.bootstrap.min.js"></script>
        <script src="{% static '' %}velonic/js/datatables/jszip.min.js"></script>
        <script src="{% static '' %}velonic/js/datatables/pdfmake.min.js"></script>
        <script src="{% static '' %}velonic/js/datatables/vfs_fonts.js"></script>
        <script src="{% static '' %}velonic/js/datatables/buttons.html5.min.js"></script>
        <script src="{% static '' %}velonic/js/datatables/buttons.print.min.js"></script>
        <script src="{% static '' %}velonic/js/datatables/dataTables.fixedHeader.min.js"></script>
        <script src="{% static '' %}velonic/js/datatables/dataTables.keyTable.min.js"></script>
        <script src="{% static '' %}velonic/js/datatables/dataTables.responsive.min.js"></script>
        <script src="{% static '' %}velonic/js/datatables/responsive.bootstrap.min.js"></script>
        <script src="{% static '' %}velonic/js/datatables/dataTables.scroller.min.js"></script>
        <script src="{% static '' %}velonic/js/bootstrap-datetimepicker.min.js"></script>
        <script src="{% static '' %}velonic/js/locales/bootstrap-datetimepicker.zh-CN.js"></script>

        <!-- Datatable init js -->
        <script src="{% static '' %}velonic/js/datatables.init.js"></script>
        <script type="text/javascript" src="//cdn.trackingmore.com/plugins/v1/plugins.min.js"></script>



        <script type="text/javascript">

            var dtTranslate={//下面是一些汉语翻译
                "sSearch": "搜索",
                "sLengthMenu": "每页显示 _MENU_",
                "sZeroRecords": "没有检索到数据",
                "sInfo": "显示 _START_ 至 _END_ 条 &nbsp;&nbsp;共 _TOTAL_ 条 &nbsp;&nbsp;",
                "sInfoFiltered": "(筛选自 _MAX_ 条数据)",
                "sInfoEmtpy": "没有数据",
                "sProcessing": "<img src='/public/images/loading.gif' /> 数据加载中...",
                "oPaginate":
                            {
                                "sFirst": "首页",
                                "sPrevious": "前一页",
                                "sNext": "后一页",
                                "sLast": "末页"
                            }
            }


            $(document).ready(function() {
                $('#datatable').dataTable({"oLanguage": dtTranslate});
                $('#datatable-responsive').DataTable({"oLanguage": dtTranslate});
                $('#datatable-buttons').DataTable();
                $('#table-evaluate').DataTable({"oLanguage": dtTranslate});
                var table = $('#datatable-fixed-header').DataTable( { fixedHeader: true,"oLanguage": dtTranslate } );
            } );
            TableManageButtons.init();





        </script>

        <script type="text/javascript">

            $('.form_date').datetimepicker({
                language:  'zh-CN',
                weekStart: 1,
                todayBtn:  1,
                autoclose: 1,
                todayHighlight: 1,
                startView: 2,
                minView: 2,
                forceParse: 0,
                startDate:'{{ mindate.send_time|date:'Y-m-d' }}',
                endDate:'{{ maxdate.send_time|date:'Y-m-d' }}'
            });


            $('#yichang').change(function(){
                var yc = $(this).children('option:selected').val();
                //window.location.href="?yc="+yc+"#yichang";//页面跳转并传参
                $.get('/api/getyichang/',{'yc':yc},function(data){
                    var wlist ='';
                    $.each($.parseJSON(data),function(k,w){
                        //console.log(w);
                        wlist +='<trid="yc-'+w.pk+'"><td><div id="TRNum-'+w.pk+'"></div><a href="javascript:void(0)" onClick="doTrack(\''+w.fields.tracking_number+'\',\''+w.pk+'\')">'+w.fields.tracking_number+'</a></td>';
                        wlist +='<td>'+w.fields.channel+'</td>';
                        var timeStr = w.fields.send_time;
                        timeStr = timeStr.replace('T',' ');
                        wlist +='<td>'+timeStr+'</td>';
                        wlist +='<td>'+w.fields.num1+'<i class="glyphicon glyphicon-pencil" title="纠错" onclick="edit(\''+w.fields.tracking_number +'\',\''+w.fields.status+'\',\''+w.fields.num1+'\')" data-toggle="modal" data-target="#editModal"></i></td><td>'+w.fields.destination+'</td>';
                        wlist +='<td class="exceptionRate" dest-data="'+w.fields.destination+'"></td>';
                        wlist +='<td><button type="button" class="btn btn-danger btn-xs" onclick="mark('+w.pk+')">标记已处理</button></td></tr>';
                    });
                    if(wlist!=''){
                        $('.yctable').html(wlist);
                        getExceptionRate();
                    }else{
                        $('.yctable').html('');
                    }
                });
            });

            $('#yujing').change(function(){
                var yj = $(this).children('option:selected').val();
                //window.location.href="?yc="+yc+"#yichang";//页面跳转并传参

                $.get('/api/getyujing/',{'yj':yj},function(data){
                    var wlist ='';
                    $.each($.parseJSON(data),function(k,w){
                        //console.log(w);
                        wlist +='<tr id="yj-'+w.pk+'"><td><div id="TRNum-'+w.pk+'"></div><a href="javascript:void(0)" onClick="doTrack(\''+w.fields.tracking_number+'\',\''+w.pk+'\')">'+w.fields.tracking_number+'</a></td>';
                        wlist +='<td>'+w.fields.channel+'</td>';
                        var timeStr = w.fields.send_time;
                        timeStr = timeStr.replace('T',' ');
                        wlist +='<td>'+timeStr+'</td>';
                        wlist +='<td>'+w.fields.num1+'<i class="glyphicon glyphicon-pencil" title="纠错" onclick="edit(\''+w.fields.tracking_number +'\',\''+w.fields.status+'\',\''+w.fields.num1+'\')" data-toggle="modal" data-target="#editModal"></i></td>';
                        wlist +='<td>'+w.fields.num2+'</td>';
                        wlist +='<td><button type="button" class="btn btn-warning btn-xs" onclick="mark('+w.pk+')">标记已处理</button></td></tr>';
                    });
                    if(wlist!=''){
                        $('.yjtable').html(wlist);
                    }else{
                        $('.yjtable').html('');
                    }
                });
            });


            $('#timeBtn').click(function(){
                var startDate = $("input[name='startDate']").val();
                var endDate = $("input[name='endDate']").val();

                if( startDate.length ==0 || endDate.length==0){
                    alert('请选择日期范围');
                    return false;
                }else{
                    $.get('/api/getpinggu/',{'sd':startDate,'ed':endDate},function(data){
                    //console.log(data);
                    var wlist ='';
                    for(var i=0;i<data.length;i++){
                        wlist +='<tr><td>'+data[i].Channel+'</td>';
                        wlist += '<td>'+data[i].Amount+'</td>';
                        wlist += '<td>'+data[i].DSR+'%</td>';
                        wlist += '<td>'+data[i].Days+'</td>';
                        wlist += '<td class="overtimeCountry" channel-data="'+data[i].Channel+'"></td>';
                        wlist += '<td><a href="#" data-toggle="modal" class="md-trigger btn btn-info btn-sm" onclick="getInfoByChannel(\''+ data[i].Channel +'\')" data-target="#channelModal">查看详情</a></td>';
                        wlist +='</tr>';
                    }
                    if(wlist!=''){
                        $('.tbPinggu').html(wlist);
                        getOvertimeCountry();
                    }else{
                        $('.tbPinggu').html('');
                    }
                });

                }

            });



            function doTrack(num,id) {
                TRACKINGMORE.trackMynumber({
                        TR_ElementId:"TRNum-"+id,      //必须，指定悬浮位置的元素ID。
                        TR_Width:800,        //可选，指定查询结果宽度，默认撑满容器。
                        TR_Height:480,       //可选，指定查询结果高度，最大高度为800px，默认撑满容器。
                        TR_ExpressCode:"0",       //可选，指定运输商，默认为自动识别。
                        TR_Lang:"cn",        //可选，指定UI语言，默认根据浏览器自动识别。
                        TR_Num:num       //必须，指定要查询的单号。
                });
            }



            function edit(track_number,status,num){
                $('#myEditModal span').html(track_number);
                $('#statusData').val(status);
                $('#dayData').val(num);
                //alert(track_number);

            }

            function mark(id){
                if (confirm("你确定已经处理完毕？")) {
                    location.href = "/logistics/mark?id="+id;
                }else{
                    return false;
                }
            }

            //获取国家详细数据
            function getInfoByCountry(country){
                if(country!=''){
                    $('#countryModal .countryName').text(country);
                    $.get('/api/getinfo/',{'country':country},function(data){
                        //console.log(data);
                        var wlist ='';
                        $.each(data,function(k,w){
                            //console.log(w);
                            wlist +='<tr class=\"item\"><td>'+w.Channel+'</td><td>'+w.Days+'</td><td>'+w.DSR+'</td><td>'+w.Amount+'</td></tr>';
                        });
                        if(wlist!=''){
                            $('#countryModal .winList').html(wlist);
                        }else{
                            $('#countryModal .winList').html('');
                        }
                    });
                }
            }

            function getInfoByChannel(channel){
                if(channel!=''){
                    $('#channelModal .channelName').text(channel);
                    $.get('/api/getinfo/',{'channel':channel},function(data){
                        //console.log(data);
                        var wlist ='';
                        $.each(data,function(k,w){
                            //console.log(w);
                            wlist +='<tr class=\"item\"><td>'+w.Country+'</td><td>'+w.Days+'</td><td>'+w.DSR+'%</td><td>'+w.Amount+'</td></tr>';
                        });
                        if(wlist!=''){
                            $('#channelModal .cnList').html(wlist);
                        }else{
                            $('#channelModal .cnList').html('');
                        }
                    });
                }
            }

            $('#saveBtn').click(function(){
                var status = $('#statusData').val();
                var days = $('#dayData').val();
                var track_number = $('#myEditModal span').html();
                //alert(track_number);

                if(parseInt(days)>0){
                    location.href = "{% url 'logistics_mark' %}?t="+track_number+"&d="+days+"&s="+status;
                    //alert('OK');
                }else{
                    alert('天数要大于0');
                }


            });

            function getOvertimeCountry(){
                var obj = $('.overtimeCountry');
                var len = obj.length;
                for(var i=0; i<len; i++){
                    //console.log(obj3[i].parentNode.parentNode.style.cssText="text-indent:0px;text-align: center;");
                    //alert(obj[i].innerHTML);
                    var channel = obj[i].getAttribute('channel-data');
                    //alert(channel);

                    var wlist = new Array();
                    //{url:"/jquery/test1.txt",async:false}
                    //$.ajax('/api/getovertime/',{'channel':channel},function(data){
                    $.ajax({url:'/api/getovertime/',async:false,data:{'channel':channel},success:function(data){
                        //console.log(data);

                        $.each(data,function(k,w){
                                //console.log(w);
                                wlist.push(w.Country);
                            });
                        obj[i].innerHTML=wlist;
                        //console.log(wlist);
                    }

                });
            }}

            function getExceptionRate(){
                var obj = $('.exceptionRate');
                var len = obj.length;
                for(var i=0; i<len; i++){
                    //console.log(obj3[i].parentNode.parentNode.style.cssText="text-indent:0px;text-align: center;");
                    //alert(obj[i].innerHTML);
                    var country = obj[i].getAttribute('dest-data');
                    //alert(channel);

                    $.ajax({url:'/api/getexceptionrate/',async:false,data:{'country':country},success:function(data){
                        //console.log(data);
                        obj[i].innerHTML=data[0].DSR+"%";
                        //console.log(wlist);
                    }

                });
            }}



        </script>



{% include 'velonic/block/footer_comm.html' %}



    </body>
</html>
